<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>YUI AOP Tests</title>
</head>

<body class="yui3-skin-sam">
<h1>AOP Tests</h1>
<p><input type="button" value="Run Tests" id="btnRun" disabled="true" /></p>

<script type="text/javascript" src="../../../build/yui/yui.js"></script>
<script type="text/javascript">

(function() {
    YUI({
        base: "../../../build/",
        filter: "debug",
        useConsole: true,
        // logInclude: ['event', 'test']
        logExclude: {Dom: true, Selector: true, Node: true, attribute: true, base: true, event: true, widget: true}
    }).use("dump", "test", "console", "event-custom", function(Y) {

        var button = Y.one('#btnRun');

        // Set up the page
        button.set("disabled", false);
        Y.on("click", function() {
            Y.Test.Runner.run();
        }, button);

        var myConsole = new Y.Console().render();

        var testEventTarget = new Y.Test.Case({
            name: "AOP tests",

            test_alter_return: function() {

                var et = new Y.EventTarget(), count = 0;

                et.after(function() {
                    count++;
                    Y.Assert.isTrue(Y.Do.originalRetVal);
                    Y.Assert.isTrue(Y.Do.currentRetVal);
                    return new Y.Do.AlterReturn("altered return", "altered");
                }, et, 'fire');

                et.after(function() {
                    count++;
                    Y.Assert.isTrue(Y.Do.originalRetVal);
                    Y.Assert.areEqual("altered", Y.Do.currentRetVal);
                }, et, 'fire');


                et.fire('yay');
                Y.Assert.areEqual(2, count);

            }
        });


        Y.Test.Runner.add(testEventTarget);
        Y.Test.Runner.run();
    });
})();
</script>
</body>
</html>
